home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / CGI / Fast.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  4.4 KB  |  154 lines

  1. package CGI::Fast;
  2.  
  3.  
  4.  
  5.  
  6. $CGI::Fast::VERSION='1.00a';
  7.  
  8. use CGI;
  9. use FCGI;
  10. @ISA = ('CGI');
  11.  
  12. while (($ignore) = each %ENV) { }
  13.  
  14. sub save_request {
  15. }
  16.  
  17. sub new {
  18.     return undef unless FCGI::accept() >= 0;
  19.     my($self,@param) = @_;
  20.     return $CGI::Q = $self->SUPER::new(@param);
  21. }
  22.  
  23. 1;
  24.  
  25. =head1 NAME
  26.  
  27. CGI::Fast - CGI Interface for Fast CGI
  28.  
  29. =head1 SYNOPSIS
  30.  
  31.     use CGI::Fast qw(:standard);
  32.     $COUNTER = 0;
  33.     while (new CGI::Fast) {
  34.     print header;
  35.     print start_html("Fast CGI Rocks");
  36.     print
  37.         h1("Fast CGI Rocks"),
  38.         "Invocation number ",b($COUNTER++),
  39.             " PID ",b($$),".",
  40.         hr;
  41.         print end_html;
  42.     }
  43.  
  44. =head1 DESCRIPTION
  45.  
  46. CGI::Fast is a subclass of the CGI object created by
  47. CGI.pm.  It is specialized to work well with the Open Market
  48. FastCGI standard, which greatly speeds up CGI scripts by
  49. turning them into persistently running server processes.  Scripts
  50. that perform time-consuming initialization processes, such as
  51. loading large modules or opening persistent database connections,
  52. will see large performance improvements.
  53.  
  54. =head1 OTHER PIECES OF THE PUZZLE
  55.  
  56. In order to use CGI::Fast you'll need a FastCGI-enabled Web
  57. server.  Open Market's server is FastCGI-savvy.  There are also
  58. freely redistributable FastCGI modules for NCSA httpd 1.5 and Apache.
  59. FastCGI-enabling modules for Microsoft Internet Information Server and
  60. Netscape Communications Server have been announced.
  61.  
  62. In addition, you'll need a version of the Perl interpreter that has
  63. been linked with the FastCGI I/O library.  Precompiled binaries are
  64. available for several platforms, including DEC Alpha, HP-UX and 
  65. SPARC/Solaris, or you can rebuild Perl from source with patches
  66. provided in the FastCGI developer's kit.  The FastCGI Perl interpreter
  67. can be used in place of your normal Perl without ill consequences.
  68.  
  69. You can find FastCGI modules for Apache and NCSA httpd, precompiled
  70. Perl interpreters, and the FastCGI developer's kit all at URL:
  71.  
  72.   http://www.fastcgi.com/
  73.  
  74. =head1 WRITING FASTCGI PERL SCRIPTS
  75.  
  76. FastCGI scripts are persistent: one or more copies of the script 
  77. are started up when the server initializes, and stay around until
  78. the server exits or they die a natural death.  After performing
  79. whatever one-time initialization it needs, the script enters a 
  80. loop waiting for incoming connections, processing the request, and
  81. waiting some more.
  82.  
  83. A typical FastCGI script will look like this:
  84.  
  85.     use CGI::Fast;
  86.     &do_some_initialization();
  87.     while ($q = new CGI::Fast) {
  88.     &process_request($q);
  89.     }
  90.  
  91. Each time there's a new request, CGI::Fast returns a
  92. CGI object to your loop.  The rest of the time your script
  93. waits in the call to new().  When the server requests that
  94. your script be terminated, new() will return undef.  You can
  95. of course exit earlier if you choose.  A new version of the
  96. script will be respawned to take its place (this may be
  97. necessary in order to avoid Perl memory leaks in long-running
  98. scripts).
  99.  
  100. CGI.pm's default CGI object mode also works.  Just modify the loop
  101. this way:
  102.  
  103.     while (new CGI::Fast) {
  104.     &process_request;
  105.     }
  106.  
  107. Calls to header(), start_form(), etc. will all operate on the
  108. current request.
  109.  
  110. =head1 INSTALLING FASTCGI SCRIPTS
  111.  
  112. See the FastCGI developer's kit documentation for full details.  On
  113. the Apache server, the following line must be added to srm.conf:
  114.  
  115.     AddType application/x-httpd-fcgi .fcgi
  116.  
  117. FastCGI scripts must end in the extension .fcgi.  For each script you
  118. install, you must add something like the following to srm.conf:
  119.  
  120.    AppClass /usr/etc/httpd/fcgi-bin/file_upload.fcgi -processes 2
  121.  
  122. This instructs Apache to launch two copies of file_upload.fcgi at 
  123. startup time.
  124.  
  125. =head1 USING FASTCGI SCRIPTS AS CGI SCRIPTS
  126.  
  127. Any script that works correctly as a FastCGI script will also work
  128. correctly when installed as a vanilla CGI script.  However it will
  129. not see any performance benefit.
  130.  
  131. =head1 CAVEATS
  132.  
  133. I haven't tested this very much.
  134.  
  135. =head1 AUTHOR INFORMATION
  136.  
  137. be used and modified freely, but I do request that this copyright
  138. notice remain attached to the file.  You may modify this module as you
  139. wish, but if you redistribute a modified version, please attach a note
  140. listing the modifications you have made.
  141.  
  142. Address bug reports and comments to:
  143. lstein@genome.wi.mit.edu
  144.  
  145. =head1 BUGS
  146.  
  147. This section intentionally left blank.
  148.  
  149. =head1 SEE ALSO
  150.  
  151. L<CGI::Carp>, L<CGI>
  152.  
  153. =cut
  154.